home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
show.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-15
|
27KB
|
746 lines
/***********************************************************************/
/* SHOW.C - Functions involving displaying the data. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\show.c 1.4 1993/09/01 16:27:15 MH Interim MH $
*/
#include <stdio.h>
#include <time.h>
#include "the.h"
#include "proto.h"
/*#define TRACEE*/
/*-------------------------- external data ----------------------------*/
extern LINE *next_line,*curr_line;
extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern char current_file; /* pointer to current file */
extern char number_of_views; /* number of views */
extern char number_of_files; /* number of open files */
extern char display_screens; /* number of screens */
extern bool horizontal;
extern WINDOW *foot,*error_window;
extern bool error_on_screen;
extern char mode_insert; /* defines insert mode toggle */
extern char in_profile; /* indicates if processing profile */
extern char file_disposition;
/*------------------------ function definitions -----------------------*/
#ifdef PROTO
static void show_line(int direction,LINE *curr,
short rows,short start_row);
#else
static void show_line();
#endif
/***********************************************************************/
#ifdef PROTO
void show_heading(void)
#else
void show_heading()
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short y,x,fpath_len,fname_len,max_name;
char buffer[60];
char display_path[MAX_FILE_NAME+1];
char *fpath = display_path;
register int i;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("show.c: show_heading");
#endif
/*---------------------------------------------------------------------*/
/* Reset idline to blank. */
/*---------------------------------------------------------------------*/
wmove(CURRENT_WINDOW_IDLINE,0,0);
my_wclrtoeol(CURRENT_WINDOW_IDLINE);
/*---------------------------------------------------------------------*/
/* Calculate line,col values. */
/*---------------------------------------------------------------------*/
getyx(CURRENT_WINDOW,y,x);
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
{
y = (short)CURRENT_VIEW->current_line;
x++;
}
else
{
y = (short)CURRENT_VIEW->focus_line;
x += CURRENT_VIEW->verify_col;
}
/*---------------------------------------------------------------------*/
/* Set up buffer for line,col,size and alt values for vertical screens.*/
/*---------------------------------------------------------------------*/
if (display_screens != 1 && !horizontal)
{
sprintf(buffer,"L=%-.1d C=%-.1d S=%-.1d A=%d,%d",
y,x,
CURRENT_FILE->number_lines,
CURRENT_FILE->autosave_alt,
CURRENT_FILE->save_alt);
max_name = (CURRENT_SCREEN.screen_cols-1) - strlen(buffer);
}
else
max_name = (CURRENT_SCREEN.screen_cols-48);
/*---------------------------------------------------------------------*/
/* Determine which portion of filename can be displayed. */
/*---------------------------------------------------------------------*/
strcpy(display_path,CURRENT_FILE->fpath);
fpath = strtrans(display_path,ISLASH,ESLASH);
fpath_len = strlen(fpath);
fname_len = strlen(CURRENT_FILE->fname);
if (fpath_len + fname_len > max_name)
{
fpath_len = (fpath_len + fname_len + 3) - max_name;
wmove(CURRENT_WINDOW_IDLINE,0,0);
wprintw(CURRENT_WINDOW_IDLINE,"...%s%s",fpath+fpath_len,CURRENT_FILE->fname);
}
else
{
wmove(CURRENT_WINDOW_IDLINE,0,0);
wprintw(CURRENT_WINDOW_IDLINE,"%s%s",fpath,CURRENT_FILE->fname);
}
if (display_screens != 1 && !horizontal)
{
wmove(CURRENT_WINDOW_IDLINE,0,max_name+1);
wprintw(CURRENT_WINDOW_IDLINE,"%-s",buffer);
}
else
{
/* wmove(CURRENT_WINDOW_IDLINE,0,34);*/
wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46);
wprintw(CURRENT_WINDOW_IDLINE,"Line=%-6.1d Col=%-5.1d",y,x);
/* wmove(CURRENT_WINDOW_IDLINE,0,54);*/
wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+20);
wprintw(CURRENT_WINDOW_IDLINE,"Size=%-6.1d",CURRENT_FILE->number_lines);
/* wmove(CURRENT_WINDOW_IDLINE,0,66);*/
wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+32);
wprintw(CURRENT_WINDOW_IDLINE,"Alt= ");
/* wmove(CURRENT_WINDOW_IDLINE,0,70);*/
wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+36);
wprintw(CURRENT_WINDOW_IDLINE,"%d,%d",CURRENT_FILE->autosave_alt,
CURRENT_FILE->save_alt);
}
wnoutrefresh(CURRENT_WINDOW_IDLINE);
#ifdef TRACE
trace_return();
#endif
return;
}
/***********************************************************************/
#ifdef PROTO
void show_footing(void)
#else
void show_footing()
#endif
/***********************************************************************/
{
/*------------------------- external data -----------------------------*/
extern char *rec;
extern char *cmd_rec;
extern char *pre_rec;
extern bool extended_display_mode;
extern bool colour_support;
extern char pending_prefix_command[PREFIX_WIDTH+1];
extern char *the_version;
extern bool CLOCKx;
extern bool HEXDISPLAYx;
/*--------------------------- local data ------------------------------*/
short y,x;
int key;
WINDOW *w;
time_t timer;
struct tm *tblock;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("show.c: show_footing");
#endif
w = CURRENT_WINDOW;
/*---------------------------------------------------------------------*/
/* Display THE version. */
/*---------------------------------------------------------------------*/
mvwaddstr(foot,0,0,"THE");
mvwaddstr(foot,0,4,the_version);
/*---------------------------------------------------------------------*/
/* Display number of files. */
/*---------------------------------------------------------------------*/
wmove(foot,0,11);
wprintw(foot,"Files=%d ",number_of_files);
/*---------------------------------------------------------------------*/
/* Display any pending prefix command warning */
/*---------------------------------------------------------------------*/
wmove(foot,0,20);
if (strcmp(pending_prefix_command,""))
wprintw(foot,"'%s' pending...",pending_prefix_command);
else